<?php

require('config.php');

$page = new rootLayoutPrint();
$translate = tmxTranslate('place_detail.xml', REP_XLAT_TEMPLATE);
$tpl_file='print_client.tpl';
$print_client = new flyLayout(REP_TPL . $tpl_file);
$print_client->start();

$language_link=$_GET['id'];
//$clientFile = modelClientFile::getListClientFile($id_client_mandatory_sale);//$status =2,3,6 
$getClientMandatory = modelClient::getClientMandatory($language_link);// Get client mandatory
$id_user=$getClientMandatory->id_user;
$getAgent = modelClient::getClientMandatoryAgent($id_user);// Get client mandatory
$getProvince = modelClient::getClientMandatoryProvince($language_link);// Get Province client
$getDistrict = modelClient::getClientMandatoryDistrict($language_link);// Get district client
$getWant = modelClient::getClientMandatoryWant($language_link);// Get Category client
$getRealEstate = modelClient::getClientMandatoryRealEstate($language_link);// Get real estate client
$getClientUser = modelClient::getClientMandatoryUser($language_link);// Get real estate client

// Get province map client
if($getProvince){
			$print_client->setVariable('province',($getProvince->title));
			$print_client->showBlock('show_province');
	
}
//get list agent
if($getAgent){
	if($getAgent->login!=''){
			$print_client->setVariable('agent_email',($getAgent->login));
			$print_client->showBlock('show_agent_email');
			}	
	if($getAgent->prenom!=''){
			$print_client->setVariable('agent_name',($getAgent->prenom));
			$print_client->showBlock('show_agent_name');
			}
	if($getAgent->phone_number!=''){
			$print_client->setVariable('agent_tel',($getAgent->phone_number));
			$print_client->showBlock('show_agent_number');
			}
}

//get display district
foreach($getDistrict as $key => $district) {
			$print_client->setVariable('district',$district->title);	
			$print_client->parseList('list_district');
		}
//get display category
foreach($getWant as $key =>$clientwant) {
	$want_label = 'label_'.(isset($_POST['language_code'])?$_POST['language_code']:$_SESSION['language_code']);
			$print_client->setVariable('category',$clientwant->$want_label);	
			$print_client->parseList('list_category');
			$print_client->showBlock('show_category');
		}
//get display real estate
foreach($getRealEstate as $key =>$realestate) {
			$print_client->setVariable('real_estate',$realestate->title);	
			$print_client->parseList('list_real_estate');
			$print_client->showBlock('show_real_estate');
		}
	//$print_client->setVariable('prenom', $getClientUser->prenom);
	//$user = modelUser::getUser($_SESSION['id_user']);
		
if($getClientUser->nom!='' || $getClientUser->prenom!=''){
			$print_client->setVariable('nom', $getClientUser->nom);
			$print_client->setVariable('prenom', $getClientUser->prenom);
			
	}
	else{$print_client->setVariable('login', $getClientUser->login);}
		
if($getClientMandatory)
	{
	$print_client->setVariable('date_creation',date('Y-m-d H:i:s',$getClientMandatory->date_creation));
	if($getClientMandatory->date_contact!=0){
			$print_client->setVariable('date_contact',date('Y-m-d',($getClientMandatory->date_contact)));
			$print_client->showBlock('show_date_contact');
			}
	if($getClientMandatory->first_name!=''){
			$print_client->setVariable('first_name',($getClientMandatory->first_name));
			$print_client->showBlock('show_first_name');
			}
	if($getClientMandatory->last_name!=''){
			$print_client->setVariable('last_name',($getClientMandatory->last_name));
			$print_client->showBlock('show_last_name');
			}
	if($getClientMandatory->gender!=''){
			$print_client->setVariable('gender',($getClientMandatory->gender));
			$print_client->showBlock('show_gender');
			}	
	if($getClientMandatory->address!=''){
			$print_client->setVariable('address',($getClientMandatory->address));
			$print_client->showBlock('show_address');
			}
	if($getClientMandatory->address_in_cambodia!=''){
			$print_client->setVariable('address_cambodia',($getClientMandatory->address_in_cambodia));
			$print_client->showBlock('show_address_cambodia');
			}
	if($getClientMandatory->nationality!=''){
			$print_client->setVariable('nationality',($getClientMandatory->nationality));
			$print_client->showBlock('show_nationality');
			}
	if($getClientMandatory->passport_number!=''){
			$print_client->setVariable('passport_number',($getClientMandatory->passport_number));
			$print_client->showBlock('show_passport_number');
			}
	if($getClientMandatory->type_visa!=''){
			$print_client->setVariable('type_visa',($getClientMandatory->type_visa));
			$print_client->showBlock('show_type_visa');
			}
	if($getClientMandatory->date_expiration!=0){
				$print_client->setVariable('date_expiration',date('Y-m-d',$getClientMandatory->date_expiration));
				$print_client->showBlock('show_date_expiration');
			}
	if($getClientMandatory->how_know!=''){
			$print_client->setVariable('how_know',($getClientMandatory->how_know));
			$print_client->showBlock('show_how_know');
			}
	if($getClientMandatory->tel!=''){
			$print_client->setVariable('tel',($getClientMandatory->tel));
			$print_client->showBlock('show_tel');
			}
	if($getClientMandatory->email!=''){
			$print_client->setVariable('email',($getClientMandatory->email));
			$print_client->showBlock('show_email');
			}
	if($getClientMandatory->email!=''){
			$print_client->setVariable('email',($getClientMandatory->email));
			$print_client->showBlock('show_email');
			}
	if($getClientMandatory->budget_buy!=''){
				$print_client->setVariable('budget_buy',$getClientMandatory->budget_buy);
				$print_client->showBlock('show_budget_buy');
				$print_client->setVariable('currency', CURRENCY);
			}
	if($getClientMandatory->budget_rent!=''){
			$print_client->setVariable('budget_rent',$getClientMandatory->budget_rent);
			$print_client->showBlock('show_budget_rent');
			$print_client->setVariable('currency', CURRENCY);
			}
	if($getClientMandatory->renovated!=''){
			$print_client->setVariable('renovated',$getClientMandatory->renovated);
			$print_client->showBlock('show_renovated');
			}
	if($getClientMandatory->resident!=''){
			$print_client->setVariable('resident',$getClientMandatory->resident);
			if($getClientMandatory->date_departure!=0){
			$print_client->setVariable('date_departure',date('Y-m-d',$getClientMandatory->date_departure));	
			}
			$print_client->showBlock('show_resident');
			}
	if($getClientMandatory->ref_if_any!=''){
			$print_client->setVariable('ref_if_any',$getClientMandatory->ref_if_any);
			$print_client->showBlock('show_ref_if_any');
			}	
	if($getClientMandatory->comment!=''){
			$print_client->setVariable('comment',$getClientMandatory->comment);
			$print_client->showBlock('show_comment');
			}
	$print_client->setVariable('client_fullname',$getClientMandatory->gender.'. '.$getClientMandatory->first_name.' '.$getClientMandatory->last_name);
	$print_client->showBlock("have_value");
	}//end if
	else
	{ 
	$print_client->showBlock("no_value");
	}
	

$print_client->stop();
$page->setBody($print_client);
$page->display();

?>